<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="https://unpkg.com/mitt/dist/mitt.umd.js"></script>

    <script>

        console.log(mitt);

        // https://github.com/developit/mitt
        //创建一个对象--
        // 添加事件
        // eb.on('click',funciton(){})
        // 移除事件
        // eb.off('click',函数名)
        // 派发事件--通知所有的观察者
        // eb.emit('click')
        let eb = mitt();

        eb.on('发文章', function (e) {
            console.log('观众1');
            console.log(e);
        })
        eb.on('发文章', function (e) {
            console.log('观众2');
            console.log(e);
        })


        setTimeout(() => {
            eb.emit('发文章', 'xxxx')
        }, 5000);



    </script>

</body>

</html>